#include<bits/stdc++.h>
using namespace std;
// #define twoqueue_stack
// #define onequeue_stack
#ifdef twoqueue_stack
class MyStack {
    queue<int> qin,qout;
public:
    MyStack() {}
    void push(int x) {
        qin.push(x);//插入qin 将剩下的内容add到后面，则最后push的一定最先pop的
        while(!qout.empty())
        {
            qin.push(qout.front());
            qout.pop();
        }
        swap(qin,qout);//交换queue1 和 queue2 的内容
    }
    int pop() {
        int ret=qout.front();
        qout.pop();
        return ret;
    }
    int top() {
        return qout.front();
    }
    bool empty() {
        return qout.empty();
    }
};
#endif
#ifdef onequeue_stack
class MyStack {
    queue<int>q;
public:
    MyStack() {}
    void push(int x) {
        q.push(x);
        int size=q.size()-1;
        while(size--)
        {
            q.push(q.front());
            q.pop();
        }
    }
    int pop() {
        int ret=q.front();
        q.pop();
        return ret;
    }
    
    int top() {
        return q.front();
    }
    
    bool empty() {
        return q.empty();
    }
};
#endif

/**
 * Your MyStack object will be instantiated and called as such:
 * MyStack* obj = new MyStack();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->top();
 * bool param_4 = obj->empty();
 */